<template>
  <el-dialog :title="handoverTitle" :visible.sync="open" width="60%" append-to-body :before-close="closeDelDialog">
    <div style="overflow-y: auto;" :style="'height:' + tableHeight + 'px'">
      <!-- istype=1  添加登记单    istype=2 打印登记单 -->
      <transferComponent istype="2" ref="childComponent" :form="form"></transferComponent>
    </div>
  </el-dialog>
</template>

<script>
import estimateTableHeight from "@/mixins/estimateTableHeight";
import transferComponent from "@/views/archive/archiveTransfer/transferComponent.vue"; //移交登记单， 登记和查看详情用
import { getOnlineReceptionById } from "@/api/archive/digitalizeReceive/electronicArchives/onlineReceivingRecords";

export default {
  name: "handover",
  props: ['open', 'handoverRow'],
  mixins: [estimateTableHeight], // 混入方法
  components:{
    transferComponent
  },
  data() {
    return {
      handoverTitle: '移交接收登记表',
      form: {},
    }
  },
  watch: {
    handoverRow: {
      handler(valNew) {
        console.log(valNew,"liuhaiorng")
        this.selectHandOverPost();
      },
      immediate: true
    }
  },
  methods: {
    selectHandOverPost() {
      if(this.handoverRow != undefined&&this.handoverRow!= null&&this.handoverRow!= "") {
        getOnlineReceptionById({id: this.handoverRow.id}).then(res=>{
            console.log(res,"sdklfjskldjfklsdj")
          if (res.data.type == 'outLine') {
            this.form = res.data
            const writtenTime = res.data.writtenTime.match(/\d+/g);
            this.form.writtenTimeYear = writtenTime[0];
            this.form.writtenTimeMouth = writtenTime[1];
            this.form.writtenTimeData = writtenTime[2];
            const auditorTime = res.data.auditorTime.match(/\d+/g);
            this.form.auditorTimeYear = auditorTime[0];
            this.form.auditorTimeMouth = auditorTime[1];
            this.form.auditorTimeData = auditorTime[2];
            const unitTime = res.data.unitTime.match(/\d+/g);
            this.form.unitTimeYear = unitTime[0];
            this.form.unitTimeMouth = unitTime[1];
            this.form.unitTimeData = unitTime[2];
          } else {
            this.form = res.data;
            const writtenTime = res.data.writtenTime.match(/\d+/g);
            this.form.writtenTimeYear = writtenTime[0];
            this.form.writtenTimeMouth = writtenTime[1];
            this.form.writtenTimeData = writtenTime[2];
            const auditorTime = res.data.auditorTime.match(/\d+/g);
            this.form.auditorTimeYear = auditorTime[0];
            this.form.auditorTimeMouth = auditorTime[1];
            this.form.auditorTimeData = auditorTime[2];
            const unitTime = res.data.unitTime.match(/\d+/g);
            this.form.unitTimeYear = unitTime[0];
            this.form.unitTimeMouth = unitTime[1];
            this.form.unitTimeData = unitTime[2];
          }
        })
      }
    },
    closeDelDialog() {
      this.$emit('closeDelDialog')
    }
  }
}
</script>

<style scoped>

</style>
